home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgramD2.iso
/
Borland
/
Borland C++ V5.02
/
APPEXPRT.PAK
/
CMDI.OWL
< prev
next >
Wrap
Text File
|
1997-05-06
|
12KB
|
406 lines
##{cheader.snp}
#include <owl/pch.h>
##@OPT_APPL_TOOLBAR
#include <owl/buttonga.h>
##@OPT_APPL_STATUSBAR
#include <owl/statusba.h>
##@QUERY_APPL_OLE_AUTO 2
#include <owl/olefacto.h>
#include <ocf/ocreg.h>
##@OPT_APPL_REGISTRY 2
#include <classlib/cmdline.h>
#include <winsys/registry.h>
##QUERY_FILE_H [[FileName]]
#include "[[FileName]]"
##<<TMDIClient QUERY_FILE_H [[FileName]]
#include "[[FileName]]"
##<<TDialog QUERY_FILE_H [[Filename]]
#include "[[Filename]]" // Definition of about dialog.
##--BEGIN-- @OPT_APPL_HELP
##@QUERY_APPL_COMMENT == VALUE_VERBOSE 3
//
// Generated help file.
//
##@QUERY_APPL_HELP [[HelpFile]]
const char HelpFileName[] = "[[HelpFile]].hlp";
##--END-- @OPT_APPL_HELP
//{{[[TApplication]] Implementation}}
##--BEGIN-- @QUERY_APPL_OLE_AUTO
//
// OLE's ITypeInfo browses this symbol table for a list of all data,
// properties, and methods exposed by this automated class.
//
DEFINE_AUTOCLASS([[TApplication]])
EXPOSE_APPLICATION([[TApplication]], "Application", "Application object", 0)
EXPOSE_QUIT("Quit", "Quit application", 0)
//{{[[TApplication]]SYM_TBL_BEGIN}}
//{{[[TApplication]]SYM_TBL_END}}
END_AUTOCLASS([[TApplication]], tfAppObject | tfCanCreate, "[[TApplication]]", 0, 0);
DEFINE_APP_DICTIONARY(AppDictionary);
static TPointer<TRegistrar> Registrar;
REGISTRATION_FORMAT_BUFFER(200)
BEGIN_REGISTRATION(ApplicationReg)
##@QUERY_OLE_GUID [[GUID]]
REGDATA(clsid, "{[[GUID]]}")
##--BEGIN-- @QUERY_PRJ_NAME [[AppTitle]]
REGDATA(progid, "[[AppTitle]].Application.1")
REGDATA(appname, "[[AppTitle]] Server")
REGDATA(description, "[[AppTitle]] Server Application")
REGDATA(cmdline, "/Automation")
// REGDATA(debugger, "TDW")
##--END-- @QUERY_PRJ_NAME [[AppTitle]]
END_REGISTRATION
##--END-- @QUERY_APPL_OLE_AUTO
##@QUERY_APPL_COMMENT == VALUE_VERBOSE 3
//
// Build a response table for all messages/commands handled by the application.
//
##@OPT_APPL_MRU
DEFINE_RESPONSE_TABLE2([[TApplication]], TRecentFiles, TApplication)
##!@OPT_APPL_MRU
DEFINE_RESPONSE_TABLE1([[TApplication]], TApplication)
//{{[[TApplication]]RSP_TBL_BEGIN}}
##@OPT_APPL_HELP 2
##:DBResponse(\\"[[TApplication]]", "CM_HELPCONTENTS", "CmHelpContents", "", "COMMAND")
##:DBResponse(\\"[[TApplication]]", "CM_HELPUSING", "CmHelpUsing", "", "COMMAND")
EV_COMMAND(CM_HELPCONTENTS, CmHelpContents),
EV_COMMAND(CM_HELPUSING, CmHelpUsing),
##:DBResponse(\\"[[TApplication]]", "CM_HELPABOUT", "CmHelpAbout", "", "COMMAND")
EV_COMMAND(CM_HELPABOUT, CmHelpAbout),
##@OPT_APPL_DRAGDROP
##:DBResponse(\\"[[TApplication]]", "", "", "WM_DROPFILES", "")
EV_WM_DROPFILES,
##@OPT_APPL_PRINTING
##:DBResponse(\\"[[TApplication]]", "", "", "WM_WININICHANGE", "")
EV_WM_WININICHANGE,
##@OPT_APPL_MRU
EV_REGISTERED(MruFileMessage, CmFileSelected),
//{{[[TApplication]]RSP_TBL_END}}
END_RESPONSE_TABLE;
##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
//--------------------------------------------------------
// [[TApplication]]
// ~~~~~
//
##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
##--BEGIN-- @QUERY_APPL_OLE_AUTO
##QUERY_WIND_TITLE [[Title]]
##@QUERY_TARGET_NAME [[Target]]
##@OPT_APPL_MRU
[[TApplication]]::[[TApplication]]() : TApplication(::ApplicationReg["appname"], ::Module, &::AppDictionary), TRecentFiles(".\\[[Target]].ini", 4)
##!@OPT_APPL_MRU
[[TApplication]]::[[TApplication]]() : TApplication(::ApplicationReg["appname"], ::Module, &::AppDictionary)
##--END-- @QUERY_APPL_OLE_AUTO
##--BEGIN-- !@QUERY_APPL_OLE_AUTO
##QUERY_WIND_TITLE [[Title]]
##@QUERY_TARGET_NAME [[Target]]
##@OPT_APPL_MRU
[[TApplication]]::[[TApplication]]() : TApplication("[[Title]]"), TRecentFiles(".\\[[Target]].ini", 4)
##QUERY_WIND_TITLE [[Title]]
##!@OPT_APPL_MRU
[[TApplication]]::[[TApplication]]() : TApplication("[[Title]]")
##--END-- !@QUERY_APPL_OLE_AUTO
{
##@OPT_APPL_HELP 3
HelpState = false;
ContextHelp = false;
HelpCursor = 0;
##@OPT_APPL_PRINTING 3
Printer = 0;
Printing = 0;
// INSERT>> Your constructor code here.
}
[[TApplication]]::~[[TApplication]]()
{
##@OPT_APPL_PRINTING 2
delete Printer;
// INSERT>> Your destructor code here.
}
##--BEGIN-- @OPT_APPL_HELP
bool [[TApplication]]::CanClose()
{
bool result = TApplication::CanClose();
##@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Close the help engine if we used it.
//
if (result && HelpState)
GetMainWindow()->WinHelp(HelpFileName, HELP_QUIT, 0);
return result;
}
##--END-- @OPT_APPL_HELP
##--BEGIN-- @OPT_APPL_TOOLBAR
void [[TApplication]]::SetupSpeedBar(TDecoratedMDIFrame* frame)
{
ApxHarbor = new THarbor(*frame);
##@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Create default toolbar New and associate toolbar buttons with commands.
//
TDockableControlBar* cb = new TDockableControlBar(frame);
cb->Insert(*new TButtonGadget(CM_MDIFILENEW, CM_MDIFILENEW));
cb->Insert(*new TButtonGadget(CM_MDIFILEOPEN, CM_MDIFILEOPEN));
cb->Insert(*new TButtonGadget(CM_FILESAVE, CM_FILESAVE));
cb->Insert(*new TSeparatorGadget(6));
cb->Insert(*new TButtonGadget(CM_EDITCUT, CM_EDITCUT));
cb->Insert(*new TButtonGadget(CM_EDITCOPY, CM_EDITCOPY));
cb->Insert(*new TButtonGadget(CM_EDITPASTE, CM_EDITPASTE));
cb->Insert(*new TSeparatorGadget(6));
cb->Insert(*new TButtonGadget(CM_EDITUNDO, CM_EDITUNDO));
cb->Insert(*new TSeparatorGadget(6));
cb->Insert(*new TButtonGadget(CM_EDITFIND, CM_EDITFIND));
cb->Insert(*new TButtonGadget(CM_EDITFINDNEXT, CM_EDITFINDNEXT));
##@OPT_APPL_PRINTING 3
cb->Insert(*new TSeparatorGadget(6));
cb->Insert(*new TButtonGadget(CM_FILEPRINT, CM_FILEPRINT));
cb->Insert(*new TButtonGadget(CM_FILEPRINTPREVIEW, CM_FILEPRINTPREVIEW));
##@OPT_APPL_HELP 2
cb->Insert(*new TSeparatorGadget(6));
cb->Insert(*new TButtonGadget(CM_HELPCONTENTS, CM_HELPCONTENTS));
##@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Add caption and fly-over help hints.
//
cb->SetCaption("Toolbar");
cb->SetHintMode(TGadgetWindow::EnterHints);
ApxHarbor->Insert(*cb, alTop);
}
##--END-- @OPT_APPL_TOOLBAR
##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
//--------------------------------------------------------
// [[TApplication]]
// ~~~~~
// Application intialization.
//
##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
void [[TApplication]]::InitMainWindow()
{
if (nCmdShow != SW_HIDE)
##@QUERY_APPL_STARTUP == VALUE_NORMAL
nCmdShow = (nCmdShow != SW_SHOWMINNOACTIVE) ? SW_SHOWNORMAL : nCmdShow;
##@QUERY_APPL_STARTUP == VALUE_MIN
nCmdShow = (nCmdShow != SW_SHOWMINNOACTIVE) ? SW_SHOWMINIMIZED : nCmdShow;
##@QUERY_APPL_STARTUP == VALUE_MAX
nCmdShow = (nCmdShow != SW_SHOWMINNOACTIVE) ? SW_SHOWMAXIMIZED : nCmdShow;
##<<TMDIClient QUERY_CLASS_NAME [[TMDIClient]]
MdiClient = new [[TMDIClient]];
##@OPT_APPL_STATUSBAR
TDecoratedMDIFrame* frame = new TDecoratedMDIFrame(Name, IDM_MDI, *MdiClient, true);
##!@OPT_APPL_STATUSBAR
TDecoratedMDIFrame* frame = new TDecoratedMDIFrame(Name, IDM_MDI, *MdiClient, false);
##QUERY_WIND_STYLE [[StyleAttributes]]
##StyleAttributes != "" 4
// Override the default window style for the main window.
//
[[StyleAttributes]]
##@OPT_APPL_DRAGDROP 4
// Enable acceptance of dropped files
//
frame->Attr.ExStyle |= WS_EX_ACCEPTFILES;
##{fwndbkgd.snp}
##@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Assign icons for this application.
//
frame->SetIcon(this, IDI_MDIAPPLICATION);
frame->SetIconSm(this, IDI_MDIAPPLICATION);
##@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Associate with the accelerator table.
//
##@QUERY_APPL_MODEL == VALUE_MDI
frame->Attr.AccelTable = IDM_MDI;
##@QUERY_APPL_MODEL == VALUE_SDI
frame->Attr.AccelTable = IDM_SDI;
##@OPT_APPL_STATUSBAR 6
TStatusBar* sb = new TStatusBar(frame, TGadget::Recessed,
TStatusBar::CapsLock |
TStatusBar::NumLock |
TStatusBar::ScrollLock);
frame->Insert(*sb, TDecoratedFrame::Bottom);
##@OPT_APPL_TOOLBAR 2
SetupSpeedBar(frame);
SetMainWindow(frame);
frame->SetMenuDescr(TMenuDescr(IDM_MDI));
##--BEGIN-- @QUERY_APPL_CONTROL == VALUE_3D
##@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Windows 3-D controls.
//
EnableCtl3d(true);
##--END-- @QUERY_APPL_CONTROL == VALUE_3D
##--BEGIN-- @QUERY_APPL_CONTROL == VALUE_BWCC
##@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Borland Windows custom controls.
//
EnableBWCC();
##--END-- @QUERY_APPL_CONTROL==VALUE_BWCC
}
##--BEGIN-- @OPT_APPL_REGISTRY
##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
//--------------------------------------------------------
// [[TApplication]]
// ~~~~~
// Application instance initialization.
//
##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
void [[TApplication]]::InitInstance()
{
TApplication::InitInstance();
ProcessCmdLine(lpCmdLine);
}
##--END-- @OPT_APPL_REGISTRY
##{registry.snp}
##--BEGIN-- @OPT_APPL_HELP
##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
//--------------------------------------------------------
// [[TApplication]]
// ~~~~~
// Menu Help Contents command
//
##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
void [[TApplication]]::CmHelpContents()
{
##@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Show the help table of contents.
//
HelpState = GetMainWindow()->WinHelp(HelpFileName, HELP_CONTENTS, 0);
}
##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
//--------------------------------------------------------
// [[TApplication]]
// ~~~~~
// Menu Help Using Help command
//
##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
void [[TApplication]]::CmHelpUsing()
{
##@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Display the contents of the Windows help file.
//
HelpState = GetMainWindow()->WinHelp(HelpFileName, HELP_HELPONHELP, 0);
}
##--END-- @OPT_APPL_HELP
##@QUERY_APPL_COMMENT == VALUE_VERBOSE 3
//--------------------------------------------------------
// [[TApplication]]
// ~~~~~~~~~~~
##@QUERY_TARGET_NAME [[Target]]
// Menu Help About [[Target]] command
//
void [[TApplication]]::CmHelpAbout()
{
##@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Show the modal dialog.
//
##<<TDialog QUERY_CLASS_NAME [[TDialog]]
[[TDialog]](MainWindow).Execute();
}
##--BEGIN-- @OPT_APPL_DRAGDROP
void [[TApplication]]::EvDropFiles(TDropInfo drop)
{
TFileDropletList files;
##@QUERY_APPL_COMMENT == VALUE_VERBOSE 3
// Iterate thru the entries in drop and create FileDrops objects for each
// one.
//
int fileCount = drop.DragQueryFileCount(); // Number of files dropped.
for (int i = 0; i < fileCount; i++)
files.Add(new TFileDroplet(drop, i));
##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Open the files that were dropped.
//
AddFiles(files);
##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Release the memory allocated for this handle with DragFinish.
//
drop.DragFinish();
}
void [[TApplication]]::AddFiles(TFileDropletList& files)
{
##<<TMDIClient QUERY_CLASS_NAME [[TMDIClient]]
[[TMDIClient]]* theClient = TYPESAFE_DOWNCAST(GetMainWindow()->GetClientWindow(), [[TMDIClient]]);
if (theClient) {
##@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Open all files dragged in.
//
for (TFileDropletListIter fileIter(files); fileIter; fileIter++)
theClient->OpenFile(fileIter.Current()->GetName());
}
}
##--END-- @OPT_APPL_DRAGDROP
##--BEGIN-- @OPT_APPL_MRU
int32 [[TApplication]]::CmFileSelected(uint wp, int32)
{
TAPointer<char> text = new char[_MAX_PATH];
GetMenuText(wp, text, _MAX_PATH);
##<<TMDIClient QUERY_CLASS_NAME [[TMDIClient]]
[[TMDIClient]]* theClient = TYPESAFE_DOWNCAST(GetMainWindow()->GetClientWindow(), [[TMDIClient]]);
if (theClient)
theClient->OpenFile(text);
return 0;
}
##--END-- @OPT_APPL_MRU
##{main.owl}